﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace WPDataBinding
{
    public class DayConverter : IValueConverter
    {
        enum Days { Monday = 1, Tueday = 2, Wenesday = 3, Thusday = 4, Friday = 5, Satday = 6, Sunday = 7 };
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
          double val = (double) value;
          int day = (int) Math.Round(val);
          //Enum.GetName(typeof(Days), day);
          Days d = (Days) day;
          String DayName = "";
          switch (d)
          {
              case Days.Monday:
                  DayName = "วันจันทร์";
                  break;
              case Days.Tueday:
                  DayName = "วันอังคาร";
                  break;
              case Days.Wenesday:
                  DayName = "วันพุธ";
                  break;
              case Days.Thusday:
                  DayName = "วันพฤหัสบดี";
                  break;
              case Days.Friday:
                  DayName = "วันศุกร์";
                  break;
              case Days.Satday:
                  DayName = "วันเสาร์";
                  break;
              case Days.Sunday:
                  DayName = "วันอาทิตย์";
                  break;
              default:
                  DayName = "วันหยุด";
                  break;
          }
         
          return DayName;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
